import request from '@/utils/request'

// 定义接口参数和返回值的类型
interface SignPoint {
  id: number
  categoryName: string
  pointName: string
  inspectorName: string
  location: string
  description: string
}

interface SignListParams {
  pointName?: string
  inspectorName?: string
  categoryName?: string
  page?: number
  pageSize?: number
}

interface SignListResponse {
  records: SignPoint[]
  total: number
}

interface Category {
  id: number
  categoryName: string
}

// 获取签到点列表
export function fetchSignList(params: SignListParams) {
  return request<SignListResponse>({
    url: '/api/safety/sign/list',
    method: 'get',
    params
  })
}

// 添加签到点
export function addSign(data: { categoryId: number; pointName: string; location: string; inspectorIds: number[]; description?: string }) {
  return request({
    url: '/api/safety/sign/add',
    method: 'post',
    data
  })
}

// 更新签到点
export function updateSign(data: { id: number; categoryId: number; pointName: string; location: string; inspectorIds: number[]; description?: string }) {
  return request({
    url: '/api/safety/sign/update',
    method: 'post',
    data
  })
}

// 删除签到点
export function deleteSign(sign: { id: number }) {
  return request({
    url: '/api/safety/sign/delete',
    method: 'post',
    data: sign
  })
}

// 获取一级分类列表（用于下拉选择）
export function fetchCategoryLevel1(params?: Record<string, any>) {
  return request<Category[]>({
    url: '/patrol/category/level1/list',
    method: 'get',
    params
  })
} 